# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=bash-completion
pkgver=2.8
pkgrel=2
pkgdesc="Programmable completion for the bash shell"
arch=('any')
url="https://bash-completion.alioth.debian.org/"
license=('GPL')
groups=('base')
depends=('bash')
options=('!emptydirs' '!makeflags')
source=(https://github.com/scop/${pkgname}/releases/download/${pkgver}/${pkgname}-${pkgver}.tar.xz
        001-quote_readline_by_ref_fixes.patch
        002-Avoid-bad-array-subscript-on-commands-ending-with-slash.patch
        003-Declare-as-global-on-bash-4.2.patch
        004-Add-support-for-not-counting-specified-option-args.patch)
sha256sums=('c01f5570f5698a0dda8dc9cfb2a83744daa1ec54758373a6e349bd903375f54d'
            'cb33b656f435b945a6ae42dace5ace56e7063152ad3fa38429a7311d491525af'
            '1fefefe124429c13e6f7fef99eda276e7d59ad72887998927dd7d81c51972c23'
            'd6916d629bd2a25d4eac83204f1f7a35400378ebff223e0d5ea97489cf7178bf'
            '23c7afac9e90e9ca732b8bd957a841419fee173e0a496a720d86aaac2566035b')
prepare() {
  cd ${pkgname}-${pkgver}
  patch -p1 -i ${srcdir}/001-quote_readline_by_ref_fixes.patch
  patch -p1 -i ${srcdir}/002-Avoid-bad-array-subscript-on-commands-ending-with-slash.patch
  patch -p1 -i ${srcdir}/003-Declare-as-global-on-bash-4.2.patch
  patch -p1 -i ${srcdir}/004-Add-support-for-not-counting-specified-option-args.patch

  autoreconf --install
}

build() {
  cd ${pkgname}-${pkgver}
  ./configure --prefix=/usr --sysconfdir=/etc
  make
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install

  rm "${pkgdir}"/usr/share/bash-completion/completions/makepkg
}
